package com.example.a2306_shop.adapter

import android.widget.LinearLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.a2306_shop.R
import com.example.lib_base.entity.ExplosiveMoney

class TypeAdapter:BaseQuickAdapter<ExplosiveMoney,BaseViewHolder>(R.layout.item_type) {
    override fun convert(holder: BaseViewHolder, item: ExplosiveMoney) {
        holder.setText(R.id.type_info,item.info)
        holder.setText(R.id.type_name,item.name)
        if(selectedType==item.type.toInt()){
            holder.getView<LinearLayout>(R.id.type_ll).setBackgroundResource(R.drawable.bg_type)
        }else{
            holder.getView<LinearLayout>(R.id.type_ll).background = null
        }
    }
    //定义一个默认选中值
    var selectedType = 4

    fun setType(type:Int){
        selectedType = type
        notifyDataSetChanged()
    }
}